#ifndef __SUBSYSTEM_RENDER_HPP__
# define __SUBSYSTEM_RENDER_HPP__

# include "core/types.hpp"
# include "core/object.hpp"
# include "core/scene_node.hpp"
# include "scripting.hpp"
# include "system.hpp"

# include <boost/shared_ptr.hpp>
# include <boost/scoped_ptr.hpp>
# include <boost/thread.hpp>
# include <boost/noncopyable.hpp>
# include <boost/tuple/tuple.hpp>

# include <string>

class render_impl_t;

/**
 * @brief Class responsible for 3D picture rendering and scene management.
 */
class render_t : private boost::noncopyable, public if_system_t
{
public:

    static boost::shared_ptr<if_system_t> create(f_engine_t *engine);

    void start(); /*override*/

    void stop();

    boost::tuple<boost::shared_ptr<scene_node_t>, vector3_t> create_entity(object_class_t &obj_class);

    scalar_t get_per_phisics_scale();

    /** --- Render API --- */
    /** {@ */

    /**
     * Camera
     */
    void create_camera(const std::string &name);
    void set_back_color(const color_t &color);
    void set_near_clip_dist(float dist);
    void set_far_clip_dist(float dist);
    void set_camera(const vector3_t &pos);
    void camera_look_at(const vector3_t &dir);

    /**
     * Light
     */
    void set_ambient_light(const color_t &color);
    void create_directional_light(const color_t &diffuse_color, const color_t &specular_color, const vector3_t &direction);

    /** @} */

    ~render_t();
private:
    render_t(f_engine_t *engine);

    void render_thr();

    boost::thread render_thr_;

    f_engine_t *engine_;

    render_impl_t *impl_;
};

#endif //__SUBSYSTEM_RENDER_HPP__
